USE [SecurityDB]
GO
/****** Object:  User [docimax]    Script Date: 2020/10/9 17:07:38 ******/
CREATE USER [docimax] FOR LOGIN [docimax] WITH DEFAULT_SCHEMA=[dbo]
GO
ALTER ROLE [db_datareader] ADD MEMBER [docimax]
GO
/****** Object:  UserDefinedFunction [dbo].[fun_getPY]    Script Date: 2020/10/9 17:07:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE function [dbo].[fun_getPY](@str nvarchar(4000)) 
returns nvarchar(4000) 
as 
begin
    declare @word nchar(1),@PY nvarchar(4000)
    set @PY=''
    set @str=replace(@str,' ','')
    while len(@str)>0 
begin
        set @word=left(@str,1)
        --如果非汉字字符，返回空 
        set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901 
then (select top 1
            PY
        from ( 
                                                                                                                                                                                                                                                                            select 'A' as PY, N'骜' as word
            union all
                select 'B', N'簿'
            union all
                select 'C', N'错'
            union all
                select 'D', N'鵽'
            union all
                select 'E', N'樲'
            union all
                select 'F', N'鳆'
            union all
                select 'G', N'腂'
            union all
                select 'H', N'夻'
            union all
                select 'J', N'攈'
            union all
                select 'K', N'穒'
            union all
                select 'L', N'鱳'
            union all
                select 'M', N'旀'
            union all
                select 'N', N'桛'
            union all
                select 'O', N'沤'
            union all
                select 'P', N'曝'
            union all
                select 'Q', N'囕'
            union all
                select 'R', N'鶸'
            union all
                select 'S', N'蜶'
            union all
                select 'T', N'箨'
            union all
                select 'W', N'鹜'
            union all
                select 'X', N'鑂'
            union all
                select 'Y', N'韵'
            union all
                select 'Z', N'咗' 
) T
        where word>=@word collate Chinese_PRC_CS_AS_KS_WS
        order by PY ASC) else '' end)
        set @str=right(@str,len(@str)-1)
    end
    return @PY
end

GO
/****** Object:  UserDefinedFunction [dbo].[GetDepartCode]    Script Date: 2020/10/9 17:07:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE function [dbo].[GetDepartCode](@code varchar(20)  )
  returns varchar(20)
  begin
    declare @departName varchar(500)
    declare @departCode varchar(20)

    select @departName=Name
    from HIS_Temp_DB.dbo.Dic_Department
    where DepCode=@code
    select @departCode= DepCode
    from SecurityDB.dbo.Base_Department
    where Name=@departName

    return @departCode
end
GO
/****** Object:  UserDefinedFunction [dbo].[GetDepartName]    Script Date: 2020/10/9 17:07:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


Create function [dbo].[GetDepartName](@code varchar(20)  )
  returns varchar(500)
  begin
    declare @departName varchar(500)
    --declare @departCode varchar(20)

    select @departName=Name
    from HIS_Temp_DB.dbo.Dic_Department
    where DepCode=@code
    --select @departCode= DepCode from SecurityDB.dbo.Base_Department where Name=@departName

    return @departName
end

GO
/****** Object:  Table [dbo].[Base_AppEvent]    Script Date: 2020/10/9 17:07:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_AppEvent]
(
    [AppEventID] [int] IDENTITY(1,1) NOT NULL,
    [AppName] [nvarchar](50) NULL,
    [Owner] [nvarchar](50) NULL,
    [Type] [nvarchar](50) NULL,
    [Message] [nvarchar](max) NULL,
    [EventTime] [datetime] NULL,
    CONSTRAINT [PK_Base_AppEvent] PRIMARY KEY CLUSTERED 
(
	[AppEventID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_ClientModel]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_ClientModel]
(
    [ClientID] [nchar](20) NOT NULL,
    [ModelID] [nchar](20) NOT NULL,
    [BeginTime] [datetime] NULL,
    [EndTime] [datetime] NULL,
    CONSTRAINT [PK_Base_Client] PRIMARY KEY CLUSTERED 
(
	[ClientID] ASC,
	[ModelID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_ClientScope]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_ClientScope]
(
    [ClientID] [nchar](20) NOT NULL,
    [ScopeId] [nchar](20) NOT NULL,
    CONSTRAINT [PK_Base_ClientScope] PRIMARY KEY CLUSTERED 
(
	[ClientID] ASC,
	[ScopeId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_ClientTrace]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_ClientTrace]
(
    [ClientTraceID] [int] IDENTITY(1,1) NOT NULL,
    [ClientID] [nchar](20) NULL,
    [CostTime] [float] NULL,
    [CostVolume] [float] NULL,
    [StartTime] [datetime] NULL,
    [EndTime] [datetime] NULL,
    [Url] [nvarchar](250) NULL,
    CONSTRAINT [PK_Base_ClientTrace] PRIMARY KEY CLUSTERED 
(
	[ClientTraceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_Department]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_Department]
(
    [ID] [nchar](20) NOT NULL,
    [ParentID] [nchar](20) NULL,
    [DepCode] [nvarchar](150) NULL,
    [Name] [nvarchar](50) NULL,
    [PrincipleID] [nchar](20) NULL,
    [Note] [nvarchar](80) NULL,
    [Phone] [nchar](15) NULL,
    [PinyinShort] [varchar](50) NULL,
    [StandardCode] [varchar](4) NULL,
    [StandardName] [nvarchar](20) NULL,
    [HQMSDepartCode] [nvarchar](50) NULL,
    [Actived] [int] NULL,
    [IsEnable] [bit] NULL,
    CONSTRAINT [PK_Base_Department] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_DepartmentRole]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_DepartmentRole]
(
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [DepartmentId] [nvarchar](20) NOT NULL,
    [RoleId] [nvarchar](20) NOT NULL,
    [BeginTime] [datetime] NULL,
    [EndTime] [datetime] NULL,
    [Positive] [bit] NOT NULL,
    CONSTRAINT [PK_Base_DepartmentRole_1] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_Event]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_Event]
(
    [EventID] [int] IDENTITY(1,1) NOT NULL,
    [Type] [varchar](50) NULL,
    [Description] [nvarchar](max) NULL,
    [Owner] [nchar](20) NULL,
    [Subject] [nchar](20) NULL,
    [EventTime] [datetime] NULL,
    CONSTRAINT [PK_BaseEvent] PRIMARY KEY CLUSTERED 
(
	[EventID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_Group]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_Group]
(
    [Id] [varchar](20) NOT NULL,
    [Name] [nvarchar](50) NULL,
    [ParentId] [varchar](20) NULL,
    [Memo] [nvarchar](max) NULL,
    [CreateTime] [datetime] NULL,
    [IsEnable] [bit] NOT NULL,
    [GroupType] [varchar](50) NULL,
    [PinyinShort] [nvarchar](50) NULL,
    [GrpCode] [nvarchar](50) NULL,
    CONSTRAINT [PK_BaseGroup] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_GroupRole]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_GroupRole]
(
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [GroupId] [nvarchar](20) NOT NULL,
    [RoleId] [nvarchar](20) NOT NULL,
    [BeginTime] [datetime] NULL,
    [EndTime] [datetime] NOT NULL,
    [Positive] [bit] NULL,
    CONSTRAINT [PK_Table_GroupRole] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_Module]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_Module]
(
    [ID] [nchar](20) NOT NULL,
    [Name] [nvarchar](50) NULL,
    [IsEnable] [bit] NULL,
    [ParentID] [nchar](20) NULL,
    [Description] [varchar](max) NULL,
    CONSTRAINT [PK_BaseModule] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_ModuleResource]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_ModuleResource]
(
    [ModuleId] [nchar](20) NOT NULL,
    [ResourceId] [nchar](20) NOT NULL,
    CONSTRAINT [PK_ModuleResource] PRIMARY KEY CLUSTERED 
(
	[ModuleId] ASC,
	[ResourceId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_Resource]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_Resource]
(
    [ResourceID] [nchar](20) NOT NULL,
    [ResourceUrl] [nvarchar](200) NULL,
    [ResourceMappingUrl] [nvarchar](200) NULL,
    CONSTRAINT [PK_Base_Resource] PRIMARY KEY CLUSTERED 
(
	[ResourceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_Role]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_Role]
(
    [ID] [nchar](20) NOT NULL,
    [Name] [nchar](30) NULL,
    [IsEnable] [bit] NULL,
    [Description] [nvarchar](150) NULL,
    [ParentID] [nchar](20) NULL,
    CONSTRAINT [PK_Base_Role] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_RoleModule]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_RoleModule]
(
    [RoleID] [nchar](20) NOT NULL,
    [ModuleID] [nchar](20) NOT NULL,
    CONSTRAINT [PK_Base_RoleResource] PRIMARY KEY CLUSTERED 
(
	[RoleID] ASC,
	[ModuleID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_RoleScope]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_RoleScope]
(
    [RoleId] [nchar](20) NOT NULL,
    [ScopeId] [nchar](20) NOT NULL,
    CONSTRAINT [PK_Base_RoleScope] PRIMARY KEY CLUSTERED 
(
	[RoleId] ASC,
	[ScopeId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_Scope]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_Scope]
(
    [ScopeID] [nchar](20) NOT NULL,
    [Name] [nchar](25) NULL,
    [Type] [nchar](20) NULL,
    [Enable] [bit] NULL,
    [Value] [nvarchar](max) NULL,
    [IsEnable] [bit] NULL,
    CONSTRAINT [PK_Base_Scope] PRIMARY KEY CLUSTERED 
(
	[ScopeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_User]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_User]
(
    [UserID] [char](20) NOT NULL,
    [UserCode] [nvarchar](50) NULL,
    [Name] [nvarchar](50) NULL,
    [Temp] [nvarchar](50) NULL,
    [UserName] [nchar](10) NULL,
    [Password] [nchar](80) NULL,
    [EmployeeId] [char](20) NULL,
    [LastLoginTime] [datetime] NULL,
    [TotalOnLineTime] [datetime] NULL,
    [IsEnable] [bit] NULL,
    [Email] [nchar](20) NULL,
    [Mobile] [nchar](15) NULL,
    [Note] [nchar](80) NULL,
    [CreateTime] [datetime] NULL,
    [Grade] [nvarchar](50) NULL,
    [Title] [nvarchar](50) NULL,
    [PinyinShort] [varchar](50) NULL,
    [Actived] [int] NULL,
    [DoctorType] [nvarchar](50) NULL,
    [DefaultDepName] [nvarchar](150) NULL,
    [DefaultDepCode] [nvarchar](50) NULL,
    [DefaultDepPinyin] [varchar](150) NULL,
    [DepartmentPinyinshort] [nvarchar](150) NULL,
    [DocOccupationNum] [varchar](100) NULL,
    [IsNew] [int] NULL,
    CONSTRAINT [PK_Base_User] PRIMARY KEY CLUSTERED 
(
	[UserID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_UserDepartment]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_UserDepartment]
(
    [UserID] [nchar](20) NOT NULL,
    [DepartmentID] [nchar](20) NOT NULL,
    CONSTRAINT [PK_Base_UserDepartment] PRIMARY KEY CLUSTERED 
(
	[UserID] ASC,
	[DepartmentID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_UserGroup]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_UserGroup]
(
    [UserId] [nvarchar](20) NOT NULL,
    [GroupId] [nvarchar](20) NOT NULL,
    CONSTRAINT [PK_Base_UserGroup] PRIMARY KEY CLUSTERED 
(
	[UserId] ASC,
	[GroupId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_UserRole]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_UserRole]
(
    [UserID] [nchar](20) NOT NULL,
    [RoleID] [nchar](20) NOT NULL,
    [BeginTime] [datetime] NULL,
    [EndTime] [datetime] NULL,
    [Positive] [bit] NOT NULL,
    [Id] [int] NULL,
    CONSTRAINT [PK_Base_UserRole] PRIMARY KEY CLUSTERED 
(
	[UserID] ASC,
	[RoleID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Base_UserTrace]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Base_UserTrace]
(
    [UserTraceID] [int] IDENTITY(1,1) NOT NULL,
    [UserName] [nchar](20) NULL,
    [CostTime] [float] NULL,
    [CostVolume] [float] NULL,
    [StartTime] [datetime] NULL,
    [EndTime] [datetime] NULL,
    [Url] [nvarchar](250) NULL,
    CONSTRAINT [PK_Base_UserTrace] PRIMARY KEY CLUSTERED 
(
	[UserTraceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Table_Account]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Table_Account]
(
    [AccountID] [nchar](20) NOT NULL,
    [Balance] [float] NULL,
    [OwnerID] [nvarchar](20) NULL,
    [LastModifyTime] [datetime] NULL,
    [Type] [nvarchar](50) NULL,
    [IsLocked] [bit] NULL,
    CONSTRAINT [PK_Table_Account] PRIMARY KEY CLUSTERED 
(
	[AccountID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Table_AccountModify]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Table_AccountModify]
(
    [AccountModifyID] [int] IDENTITY(1,1) NOT NULL,
    [Balance] [float] NULL,
    [AccountID] [nchar](20) NULL,
    [Time] [datetime] NULL,
    [OperateWay] [nvarchar](50) NULL,
    [OperateMemo] [nvarchar](80) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Table_AccountRole]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Table_AccountRole]
(
    [AccountRoleID] [int] IDENTITY(1,1) NOT NULL,
    [AccountRoleType] [nchar](10) NULL,
    [AccountRoleValue] [float] NULL,
    [AccountID] [nchar](20) NULL,
    [PerTrade] [bit] NOT NULL,
    [PerDay] [bit] NOT NULL,
    [PerWeek] [bit] NOT NULL,
    [PerMonth] [bit] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Table_Trade]    Script Date: 2020/10/9 17:07:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Table_Trade]
(
    [TradeID] [int] IDENTITY(1,1) NOT NULL,
    [PayWay] [bit] NULL,
    [Time] [datetime] NULL,
    [Value] [float] NULL,
    [Cost] [float] NULL,
    [Source] [nchar](20) NULL,
    [Target] [nchar](20) NULL,
    [Memo] [nvarchar](max) NULL,
    [Type] [nvarchar](50) NULL,
    CONSTRAINT [PK_Table_Trade] PRIMARY KEY CLUSTERED 
(
	[TradeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[Base_DepartmentRole] ADD  CONSTRAINT [DF_Base_DepartmentRole_Positive]  DEFAULT ((1)) FOR [Positive]
GO
ALTER TABLE [dbo].[Base_Group] ADD  CONSTRAINT [DF_BaseGroup_IsEnable]  DEFAULT ((1)) FOR [IsEnable]
GO
ALTER TABLE [dbo].[Base_GroupRole] ADD  CONSTRAINT [DF_Table_GroupRole_Positive]  DEFAULT ((1)) FOR [Positive]
GO
ALTER TABLE [dbo].[Base_User] ADD  CONSTRAINT [DF_Base_User_CreateTime]  DEFAULT (getdate()) FOR [CreateTime]
GO
ALTER TABLE [dbo].[Base_UserRole] ADD  CONSTRAINT [DF_Base_UserRole_Positive]  DEFAULT ((1)) FOR [Positive]
GO
ALTER TABLE [dbo].[Table_Account] ADD  CONSTRAINT [DF_Table_Account_IsLocked]  DEFAULT ((0)) FOR [IsLocked]
GO
ALTER TABLE [dbo].[Table_AccountRole] ADD  CONSTRAINT [DF_Table_AccountRole_PerTrade]  DEFAULT ((1)) FOR [PerTrade]
GO
ALTER TABLE [dbo].[Table_AccountRole] ADD  CONSTRAINT [DF_Table_AccountRole_PerDay]  DEFAULT ((0)) FOR [PerDay]
GO
ALTER TABLE [dbo].[Table_AccountRole] ADD  CONSTRAINT [DF_Table_AccountRole_PerWeek]  DEFAULT ((0)) FOR [PerWeek]
GO
ALTER TABLE [dbo].[Table_AccountRole] ADD  CONSTRAINT [DF_Table_AccountRole_PerMonth]  DEFAULT ((0)) FOR [PerMonth]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'webAPI or Portal Model' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Base_Resource', @level2type=N'COLUMN',@level2name=N'ResourceMappingUrl'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户编码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Base_User', @level2type=N'COLUMN',@level2name=N'UserCode'
GO
